package Vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import modelo.Alumno;
import modelo.Curso;
import modelo.Materia;
import modelo.Profesor;

import Controlador.Sistema;

import test.Test;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Menu extends javax.swing.JFrame {
	private JButton btnAsociacion;
	private JButton btnSalir;
	private JButton jButton1;
	private JButton jButton2;
	private JButton btnAdministracion;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Menu inst = new Menu();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public Menu() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Menu!");
			getContentPane().setLayout(null);
			{
				/*esto es un alto HARDCODE*/
				Sistema sistema = new Sistema();
				
				Materia materia = new Materia("LV","35001");
				Materia materia2 = new Materia("POO","35000");
				Materia materia3 = new Materia("SSD","35002");
				Alumno alumno = new Alumno(128477,"ab","A");
				Alumno alumno2 = new Alumno(128478,"sv","A");
				Alumno alumno3 = new Alumno(128479,"hp","A");
				Profesor profe = new Profesor(10001,"CG",null);
				Profesor profe2 = new Profesor(10002,"PM",null);
				Profesor profe3 = new Profesor(10003,"JZ",null);
				
				sistema.agregarMateria(materia3);
				sistema.agregarMateria(materia2);
				sistema.agregarMateria(materia);
				sistema.agregarAlumno(alumno3);
				sistema.agregarAlumno(alumno2);
				sistema.agregarAlumno(alumno);
				sistema.agregarProfesor(profe);
				sistema.agregarProfesor(profe2);
				sistema.agregarProfesor(profe3);
				
				materia = sistema.buscarMateria("35001");
				profe = sistema.buscarProfesor(10001);
				
				sistema.crearCurso(materia,profe,100);
				
				Curso curso = sistema.buscarCurso(45);
				
				sistema.asignarAlumnoACurso(alumno, curso);
				sistema.asignarAlumnoACurso(alumno3, curso);
				
				System.out.println(curso.getAlumnos().size());
				
				sistema.AsignarMateriaAProfesor(materia, profe);
				/**System.out.println("materias: "+profe.getMaterias().size());
				
				System.out.println(materia.getNombre());
				**/
				/*esto es un alto HARDCODE*/				
				
				btnAsociacion = new JButton();
				getContentPane().add(btnAsociacion);
				btnAsociacion.setText("VentAsociaciones");
				btnAsociacion.setBounds(111, 94, 146, 21);
				btnAsociacion.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						VentAsociaciones a = new VentAsociaciones();
						a.setVisible(true);
						a.setLocationRelativeTo(null);
					}
				});
			}
			{
				btnAdministracion = new JButton();
				getContentPane().add(btnAdministracion);
				btnAdministracion.setText("Administracion");
				btnAdministracion.setBounds(111, 37, 146, 21);
				btnAdministracion.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						VentAdministracion a = new VentAdministracion();
						a.setVisible(true);
						a.setLocationRelativeTo(null);
				
					}
				});
			}
			{
				btnSalir = new JButton();
				getContentPane().add(btnSalir);
				btnSalir.setText("Salir");
				btnSalir.setBounds(154, 177, 62, 21);
				btnSalir.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1);
				jButton1.setText("Salir");
				jButton1.setBounds(154, 177, 62, 21);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			{
				jButton2 = new JButton();
				getContentPane().add(jButton2);
				jButton2.setText("Administracion");
				jButton2.setBounds(111, 37, 146, 21);
				jButton2.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButton2.actionPerformed, event="+evt);
						//TODO add your code for jButton2.actionPerformed
					}
				});
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	
	
	}
	
	private void jButton2ActionPerformed(ActionEvent evt) {
		System.out.println("jButton2.actionPerformed, event="+evt);
		//TODO add your code for jButton2.actionPerformed
	}

}
